<template>
  <button class="button">
    <slot></slot>
  </button>
</template>

<script setup lang="ts">

</script>

<style lang="scss" scoped>
  button,
  button::after {
    cursor: pointer;
    padding: 16Px 20Px;
    font-size: 18Px;
    background: linear-gradient(45deg, transparent 5%, #ff013c 5%);
    border: 0;
    color: #fff;
    letter-spacing: 3Px;
    line-height: 1;
    box-shadow: 6Px 0Px 0Px #00e6f6;
    outline: transparent;
    position: relative;
  }

  button::after {
    --slice-0: inset(50% 50% 50% 50%);
    --slice-1: inset(80% -6Px 0 0);
    --slice-2: inset(50% -6Px 30% 0);
    --slice-3: inset(10% -6Px 85% 0);
    --slice-4: inset(40% -6Px 43% 0);
    --slice-5: inset(80% -6Px 5% 0);
    content: "HOVER ME";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 3%, #00e6f6 3%, #00e6f6 5%, #ff013c 5%);
    text-shadow: -3Px -3Px 0Px #f8f005, 3Px 3Px 0Px #00e6f6;
    clip-path: var(--slice-0);
  }

  button:hover::after {
    animation: 1s glitch;
    animation-timing-function: steps(2, end);
  }

  @keyframes glitch {
    0% {
      clip-path: var(--slice-1);
      transform: translate(-20Px, -10Px);
    }

    10% {
      clip-path: var(--slice-3);
      transform: translate(10Px, 10Px);
    }

    20% {
      clip-path: var(--slice-1);
      transform: translate(-10Px, 10Px);
    }

    30% {
      clip-path: var(--slice-3);
      transform: translate(0Px, 5Px);
    }

    40% {
      clip-path: var(--slice-2);
      transform: translate(-5Px, 0Px);
    }

    50% {
      clip-path: var(--slice-3);
      transform: translate(5Px, 0Px);
    }

    60% {
      clip-path: var(--slice-4);
      transform: translate(5Px, 10Px);
    }

    70% {
      clip-path: var(--slice-2);
      transform: translate(-10Px, 10Px);
    }

    80% {
      clip-path: var(--slice-5);
      transform: translate(20Px, -10Px);
    }

    90% {
      clip-path: var(--slice-1);
      transform: translate(-10Px, 0Px);
    }

    100% {
      clip-path: var(--slice-1);
      transform: translate(0);
    }
  }
</style>